package xyz.kail.demo;

import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
import org.springframework.aop.framework.AdvisedSupport;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.aop.framework.adapter.DefaultAdvisorAdapterRegistry;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {

    public static void main(String[] args) {

//        ProxyFactory proxyFactory = new ProxyFactory();
//        // 设置目标类
//        proxyFactory.setTarget(new Hello());
//        // 设置通知
//        proxyFactory.addAdvice(new HelloAdvice());
//
//        proxyFactory.setExposeProxy(true);
//
//        Hello hello = (Hello) proxyFactory.getProxy();

//        hello.say("ad");
//        System.out.println();
//        hello.say2("ad");

//        ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
//        proxyFactoryBean.setTarget(new Hello());
//        proxyFactoryBean.addAdvice(new HelloAdvice());
//        proxyFactoryBean.setExposeProxy(true);
//        Hello hello = (Hello) proxyFactoryBean.getObject();
//
//        hello.say("ad");
//        System.out.println();
//        hello.say2("ad");

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml");
        HelloI hello = context.getBean("hello", HelloI.class);
        hello.say("asd");
        System.out.println(hello.getClass());
    }

}
